package com.maozzi.service.acl.domain.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maozzi.service.acl.domain.RolePermissionDomainService;
import com.maozzi.service.acl.repository.mapper.RolePermissionMapper;
import com.maozzi.service.acl.repository.model.RolePermission;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 权限 - 角色对应权限 domain service
 *
 * @author maozi
 */
@Service
public class RolePermissionDomainServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionDomainService {

    @Resource
    private RolePermissionMapper rolePermissionMapper;

    @Override
    public List<RolePermission> getRolePermission(Long roleId) {
        return rolePermissionMapper.selectList(Wrappers.lambdaQuery(RolePermission.class)
                .eq(RolePermission::getRoleId, roleId)
        );
    }

    @Override
    public List<RolePermission> getRolePermissions(List<Long> roleIds) {
        return rolePermissionMapper.selectList(Wrappers.lambdaQuery(RolePermission.class)
                .in(RolePermission::getRoleId, roleIds)
        );
    }
}
